<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="kyssion-blog">
<meta property="og:url" content="http://yoursite.com/page/7/index.html">
<meta property="og:site_name" content="kyssion-blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="kyssion-blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/page/7/"/>





  <title>kyssion-blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">kyssion-blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-schedule">
          <a href="/schedule/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
            
            日程表
          </a>
        </li>
      
        
        <li class="menu-item menu-item-sitemap">
          <a href="/sitemap.xml" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br />
            
            站点地图
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/java-虚拟机的锁优化技术/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/java-虚拟机的锁优化技术/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="自旋锁与自适应自旋"><a href="#自旋锁与自适应自旋" class="headerlink" title="自旋锁与自适应自旋"></a>自旋锁与自适应自旋</h3><p>虚拟机的开发团队也注意到在许多应用上,<strong>共享数据的锁定状态只会持续很短的一段时间</strong>,为了这段时间去挂起和恢复线程并不值得。如果物理机器有一个以上的处理器,能让两个或以上的线程同时并行执行,我们就可以<strong>让后面请求锁的那个线程“稍等一下”,但不放弃处理器的执行时间,看看持有锁的线程是否很快就会释放锁</strong>。为了让线程等待,我们只需让线程执行一个忙循环(自旋),这项技术就是所谓的<strong>自旋锁</strong></p>
<ul>
<li>注意：如果自旋超过了限定的次数仍然没有成功获得锁,就应当使用传统的方式去挂起线程了。自旋次数的默认值是10次,用户可以使用参数-XX:PreBlockSpin来更改</li>
</ul>
<p>在JDK 1.6中引入了自适应的自旋锁。自适应意味着自旋的时间不再固定了,而是由前一次在同一个锁上的自旋时间及锁的拥有者的状态来决定。自旋成功率高就自旋多次，反之就减少</p>
<h3 id="锁消除"><a href="#锁消除" class="headerlink" title="锁消除"></a>锁消除</h3><p>锁消除是指虚拟机即时编译器在运行时,对一些代码上要求同步,但是被检测到不可能存在共享数据竞争的锁进行消除。锁消除的主要判定依据来源于逃逸分析的数据支持(第11章已经讲解过逃逸分析技术),如果判断在一段代码中,堆上的所有数据都不会逃逸出去从而被其他线程访问到,那就可以把它们当做栈上数据对待,认为它们是线程私有的,同步加锁自然就无须进行</p>
<blockquote>
<p>简单总结，就是编辑器分析出这段代码并不需要进行上锁就不进行同步处理</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">concatString</span><span class="params">(String s1, String s2, String s3)</span> </span>&#123;</span><br><span class="line">	StringBuffer sb = <span class="keyword">new</span> StringBuffer();</span><br><span class="line">	sb.append(s1);</span><br><span class="line">	sb.append(s2);</span><br><span class="line">	sb.append(s3);</span><br><span class="line">	<span class="keyword">return</span> sb.toString();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>上面代码中每个StringBuffer.append()方法中都有一个同步块,锁就是sb对象。虚拟机观察变量sb,很快就会发现它的动态作用域被限制在concatString()方法内部。也就是说,sb的所有引用永远不会“逃逸”到concatString()方法之外,其他线程无法访问到它,因此,虽然这里有锁,但是可以被安全地消除掉,在即时编译之后,这段代码就会忽略掉所有的同步而直接执行了</p>
<h3 id="锁粗化"><a href="#锁粗化" class="headerlink" title="锁粗化"></a>锁粗化</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">concatString</span><span class="params">(String s1, String s2, String s3)</span> </span>&#123;</span><br><span class="line">	StringBuffer sb = <span class="keyword">null</span>;</span><br><span class="line">	<span class="keyword">synchronized</span> (<span class="keyword">this</span>) &#123;</span><br><span class="line">		sb = <span class="keyword">new</span> StringBuffer();</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">synchronized</span> (<span class="keyword">this</span>) &#123;</span><br><span class="line">		sb.append(s1);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">synchronized</span> (<span class="keyword">this</span>) &#123;</span><br><span class="line">		sb.append(s2);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">synchronized</span> (<span class="keyword">this</span>) &#123;</span><br><span class="line">		sb.append(s3);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> sb.toString();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>如果一系列的连续操作都对同一个对象反复加锁和解锁,甚至加锁操作是出现在循环体中的,那即使没有线程竞争,频繁地进行互斥同步操作也会导致不必要的性能损耗</p>
<blockquote>
<p>连续的append()方法就属于这类情况。如果虚拟机探测到有这样一串零碎的操作都对同一个对象加锁,将会把加锁同步的范围扩展(粗化)到整个操作序列的外部,以代码清单13-7为例,就是扩展到第一个append()操作之前直至最后一个append()操作之后,这样只需要加锁一次就可以了</p>
</blockquote>
<h3 id="偏向锁和轻量级锁和重量级锁介绍"><a href="#偏向锁和轻量级锁和重量级锁介绍" class="headerlink" title="偏向锁和轻量级锁和重量级锁介绍"></a>偏向锁和轻量级锁和重量级锁介绍</h3><p>在了解锁的时候首先需要理解java的对象头</p>
<p><strong>java对象头</strong>：所有锁的实现都依赖于对象头</p>
<ul>
<li>锁是存在Java对象头里的。如果对象是数组类型,则虚拟机用3个字宽(Word)存储对象头,如果对象是非数组类型,则用2字宽存储对象头。在32位虚拟机中,1字宽等于4字节,即32bit,如表</li>
</ul>
<p><img src="/blogimg/java/5.png" alt=""></p>
<ul>
<li>Java对象头里的Mark Word里默认存储对象的HashCode、分代年龄和锁标记位。32位JVM的Mark Word的默认存储结构如表</li>
</ul>
<p><img src="/blogimg/java/6.png" alt=""></p>
<p>java中锁一共有4种状态,级别从低到高依次是:无锁状态、偏向锁状态、轻量级锁状态和重量级锁状态,这几个状态会随着竞争情况逐渐升级。锁可以升级但不能降级,意味着偏向锁升级成轻量级锁后不能降级成偏向锁。这种锁升级却不能降级的策略,目的是为了提高获得锁和释放锁的效率</p>
<h4 id="偏向锁"><a href="#偏向锁" class="headerlink" title="偏向锁"></a>偏向锁</h4><p>大多数情况下,锁不仅不存在多线程竞争,而且总是由同一线程多次获得</p>
<p>过程：一个线程访问同步块并获取锁时,会在对象头和栈帧中的锁记录里存储锁偏向的线程ID,以后该线程在进入和退出同步块时不需要进行CAS操作来加锁和解锁,只需简单地测试一下对象头的Mark Word里是否存储着指向当前线程的偏向锁。如果测试成功,表示线程已经获得了锁。如果测试失败,则需要再测试一下Mark Word中偏向锁的标识是否设置成1(表示当前是偏向锁):如果没有设置,则使用CAS竞争锁;如果设置了,则尝试使用CAS将对象头的偏向锁指向当前线程。</p>
<p><img src="/blogimg/java/7.png" alt=""></p>
<h4 id="轻量级锁"><a href="#轻量级锁" class="headerlink" title="轻量级锁"></a>轻量级锁</h4><ul>
<li>获取锁过程</li>
</ul>
<p>线程在执行同步块之前,JVM会先在当前线程的栈桢中创建用于存储锁记录的空间,并将对象头中的Mark Word复制到锁记录中,官方称为Displaced Mark Word。然后线程尝试使用CAS将对象头中的Mark Word替换为指向锁记录的指针。如果成功,当前线程获得锁,如果失败,表示其他线程竞争锁,当前线程便尝试使用自旋来获取锁。</p>
<ul>
<li>解锁过程</li>
</ul>
<p>轻量级解锁时,会使用原子的CAS操作将Displaced Mark Word替换回到对象头,如果成功,则表示没有竞争发生。如果失败,表示当前锁存在竞争,锁就会膨胀成重量级锁。</p>
<p><img src="/blogimg/java/8.png" alt=""></p>
<p>因为自旋会消耗CPU,为了避免无用的自旋(比如获得锁的线程被阻塞住了),一旦锁升级成重量级锁,就不会再恢复到轻量级锁状态。当锁处于这个状态下,其他线程试图获取锁时,都会被阻塞住,当持有锁的线程释放锁之后会唤醒这些线程,被唤醒的线程就会进行新一轮的夺锁之争</p>
<p><img src="/blogimg/java/9.png" alt=""></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/jdbc驱动使用详解（一）基本使用方法/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/jdbc驱动使用详解（一）基本使用方法/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="java-jdbc驱动使用详解（一）基本使用方法"><a href="#java-jdbc驱动使用详解（一）基本使用方法" class="headerlink" title="java-jdbc驱动使用详解（一）基本使用方法"></a>java-jdbc驱动使用详解（一）基本使用方法</h2><p>大多数时候我都都是使用mybatis 或者数据库链接池这样的框架，渐渐对底层jdbc驱动缺少研究这里一下整理</p>
<h3 id="驱动驱动加载"><a href="#驱动驱动加载" class="headerlink" title="驱动驱动加载"></a>驱动驱动加载</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Class.forName(<span class="string">"com.mysql.jdbc.Driver"</span>);</span><br></pre></td></tr></table></figure>
<p>jvm在运行的时候，必须手动加载jdbc的驱动程序，因为jvm不会自动导入驱动，导致DriverManager无法使用</p>
<h3 id="Connection-链接"><a href="#Connection-链接" class="headerlink" title="Connection 链接"></a>Connection 链接</h3><blockquote>
<p>建立和数据库的链接（java程序一般使用数据链接池，这里只是做一些基本的介绍）</p>
</blockquote>
<blockquote>
<p>链接方法：直接设置或者使用Property</p>
</blockquote>
<ol>
<li>创建方法</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Properties properties= <span class="keyword">new</span> Properties();</span><br><span class="line">properties.setProperty(<span class="string">"xxx"</span>, <span class="string">"xxx"</span>);</span><br><span class="line">Connection connection =DriverManager.getConnection(<span class="string">"xxx"</span>,properties);</span><br><span class="line">Connection connection = DriverManager.getConnection(<span class="string">"jdbc:mysql://127.0.0.1:3306/mysql"</span>, <span class="string">"root"</span>,<span class="string">"****"</span>);</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>链接控制</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">connection.getClientInfo(<span class="string">"root"</span>);<span class="comment">//获得数据连接中的指定参数比如上面的</span></span><br><span class="line">connection.setClientInfo(<span class="keyword">new</span> Properties());</span><br><span class="line">connection.setReadOnly(<span class="keyword">true</span>);<span class="comment">//设置数据库只读</span></span><br><span class="line">connection.setAutoCommit(<span class="keyword">false</span>);<span class="comment">//关闭自动提交</span></span><br><span class="line">connection.commit();<span class="comment">//提交事物</span></span><br><span class="line">connection.rollback();<span class="comment">//事物回滚</span></span><br><span class="line">connection.close();<span class="comment">//关闭数据库</span></span><br></pre></td></tr></table></figure>
<ol start="3">
<li>链接状态检测</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">connection.isReadOnly();<span class="comment">//是否只读</span></span><br><span class="line">connection.isClosed();<span class="comment">//判断对象是否关闭了</span></span><br></pre></td></tr></table></figure>
<h3 id="数据库交互-statement"><a href="#数据库交互-statement" class="headerlink" title="数据库交互 statement"></a>数据库交互 statement</h3><p>jdbc中有三种交互方法</p>
<ul>
<li>Statement 使用通用访问数据库。当在运行时使用静态SQL语句。 Statement接口不能接受的参数。</li>
<li>PreparedStatement 当计划多次使用SQL语句。 那么可以PreparedStatement接口接收在运行时输入参数。</li>
<li>CallableStatement 当要访问数据库中的存储过程中使用。 CallableStatement对象的接口还可以接受运行时输入参数</li>
</ul>
<ol>
<li>statement对象，一般不使用，一般做心跳检测的时候使用</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Statement statement = connection.createStatement();</span><br><span class="line">statement.execute(<span class="string">""</span>);<span class="comment">//执行任何语句判断是否有result结果集有就返回投入哦否则返回false</span></span><br><span class="line">statement.executeUpdate(<span class="string">"sdfasfd"</span>);<span class="comment">//传入sql语句并且返回返回收到影响的行数</span></span><br><span class="line">statement.executeQuery(<span class="string">"sdf"</span>);<span class="comment">//传入结果集并且返回resultset结果集对象</span></span><br></pre></td></tr></table></figure>
<ol start="2">
<li>PreparedStatement — statement升级版可以使用占位符 和进行批处理操作</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">preparedStatement.setString(<span class="number">0</span>, <span class="string">"sdf"</span>);</span><br><span class="line">preparedStatement.setString(<span class="number">2</span>, <span class="string">"sdf"</span>);</span><br><span class="line">preparedStatement.setString(<span class="number">0</span>, <span class="string">"sdf"</span>);</span><br><span class="line">preparedStatement.setString(<span class="number">0</span>, <span class="string">"sdf"</span>);</span><br><span class="line">preparedStatement.addBatch();</span><br><span class="line">preparedStatement.executeBatch();<span class="comment">//提交批量操作</span></span><br></pre></td></tr></table></figure>
<h3 id="jdbc结果集操作"><a href="#jdbc结果集操作" class="headerlink" title="jdbc结果集操作"></a>jdbc结果集操作</h3><ol>
<li>声明结果集的类型  在statement的生成方法可以进行很多的配置参数 Rstyoe RsConcurrency都是ResultSet中指定的类型</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">createStatement(<span class="keyword">int</span> RSType, <span class="keyword">int</span> RSConcurrency);</span><br><span class="line">prepareStatement(String SQL, <span class="keyword">int</span> RSType, <span class="keyword">int</span> RSConcurrency);</span><br><span class="line">prepareCall(String sql, <span class="keyword">int</span> RSType, <span class="keyword">int</span> RSConcurrency);</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>ResultSet的类型 RSType</li>
</ol>
<p>可能的RSType如下，如果不指定ResultSet类型，将自动获得一个是TYPE_FORWARD_ONLY。</p>
<p>Type 描述:</p>
<ul>
<li>ResultSet.TYPE_FORWARD_ONLY 游标只能向前移动的结果集。</li>
<li>ResultSet.TYPE_SCROLL_INSENSITIVE 游标可以向前和向后滚动，结果集不是别人向创建结果集后发生的数据库更改敏感。</li>
<li>ResultSet.TYPE_SCROLL_SENSITIVE. 游标可以向前和向后滚动，结果集是别人向创建结果集后发生的数据库更改敏感。</li>
</ul>
<ol start="3">
<li>并发性的ResultSe RSConcurrencyt</li>
</ol>
<p>可能的RSConcurrency如下，如果不指定任何并发类型，将自动获得一个为CONCUR_READ_ONLY。</p>
<p>并发 描述:</p>
<ul>
<li>ResultSet.CONCUR_READ_ONLY 创建结果集只读。这是默认的</li>
<li>ResultSet.CONCUR_UPDATABLE 创建一个可更新的结果集。</li>
</ul>
<p>结果集相关方法:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ResultSet resultSet = preparedStatement.executeQuery(<span class="string">"asdasd"</span>);</span><br></pre></td></tr></table></figure>
<ol>
<li>使用可滚动结果集相关属性 需要指定 Resultset相关配置</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">resultSet.absolute(<span class="number">10</span>);<span class="comment">//游标定位到指定的位置</span></span><br><span class="line">resultSet.relative(-<span class="number">10</span>);<span class="comment">//游标向前向后移动指定的行</span></span><br><span class="line">resultSet.previous();</span><br><span class="line">resultSet.next();</span><br><span class="line">resultSet.getRow();<span class="comment">//获得行号</span></span><br></pre></td></tr></table></figure>
<ol start="2">
<li>并发性（可修改结果集相关配置）</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//更行数据库中的数据---在可进行更新的结果集中进行的修改</span></span><br><span class="line">resultSet.updateInt(<span class="string">"s"</span>, <span class="number">0</span>);<span class="comment">//-----进行修改---参数有很多updateString  第一个参数列名称 第二个参数 数值</span></span><br><span class="line">resultSet.updateRow();<span class="comment">//提交updatexx事物</span></span><br><span class="line">resultSet.deleteRow();<span class="comment">//删除数据库中的当前行---刷新后生效</span></span><br><span class="line">resultSet.insertRow();<span class="comment">//提交updatexx事物----使用插入方法</span></span><br><span class="line">resultSet.refreshRow();<span class="comment">//刷新</span></span><br><span class="line">resultSet.cancelRowUpdates();<span class="comment">//取消</span></span><br></pre></td></tr></table></figure>
<ol start="3">
<li>结果集通用方法</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//指定结果集所在的位置</span></span><br><span class="line">resultSet.beforeFirst();</span><br><span class="line">resultSet.afterLast();</span><br><span class="line">resultSet.first();</span><br><span class="line">resultSet.last();</span><br><span class="line"><span class="comment">//获得结果集中的数据</span></span><br><span class="line">resultSet.getInt(<span class="string">"sdfsdf"</span>);</span><br><span class="line">resultSet.getInt(<span class="number">0</span>);</span><br><span class="line"><span class="comment">//结果集状态</span></span><br><span class="line">resultSet.isAfterLast();</span><br><span class="line">resultSet.isBeforeFirst();</span><br><span class="line">resultSet.isClosed();</span><br><span class="line">resultSet.isFirst();</span><br><span class="line">resultSet.isClosed();</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/jdbc驱动使用详解（二）批处理性能优化/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/jdbc驱动使用详解（二）批处理性能优化/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="java-jdbc驱动使用详解（二）批处理性能优化"><a href="#java-jdbc驱动使用详解（二）批处理性能优化" class="headerlink" title="java-jdbc驱动使用详解（二）批处理性能优化"></a>java-jdbc驱动使用详解（二）批处理性能优化</h2><blockquote>
<p>在使用mysql的时候或多或少会遇见大量的批操作的情况这里整理一下经验</p>
</blockquote>
<p>这里我们对三种情况进行测试</p>
<blockquote>
<p>性能优化的方法，在url请求中加上这些参数，useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true</p>
</blockquote>
<table>
<thead>
<tr>
<th>组号</th>
<th>是否开起服务端预处理和预处理缓存</th>
<th>是否使用事务提交方法</th>
<th>是否使用批处理方法</th>
<th>1w（毫秒）</th>
<th>100w（毫秒）</th>
</tr>
</thead>
<tbody>
<tr>
<td>第一组</td>
<td>N</td>
<td>N</td>
<td>N</td>
<td>添加 : 39619，修改 : 41440，删除 : 39734</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第二组</td>
<td>Y</td>
<td>N</td>
<td>N</td>
<td>添加 : 38741，修改 : 41146，删除 : 39538</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第三组</td>
<td>N</td>
<td>Y</td>
<td>N</td>
<td>添加 : 1145，修改 : 1321，删除 : 926</td>
<td>添加 : 80560，修改 : 122566，删除 : 92001</td>
</tr>
<tr>
<td>第四组</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
<td>添加 : 674，修改 : 1114，删除 : 859</td>
<td>添加 : 76134，修改 : 116780，删除 : 88954</td>
</tr>
<tr>
<td>第五组</td>
<td>N</td>
<td>N</td>
<td>Y</td>
<td>添加 : 72，修改 : 38930，删除 : 37931</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第六组</td>
<td>Y</td>
<td>N</td>
<td>Y</td>
<td>添加 : 112，修改 : 38409，删除 : 37677</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第七组</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
<td>添加 : 54，修改 : 770，删除 : 510</td>
<td>添加 : 8925，修改 : 79631，删除 : 46655</td>
</tr>
<tr>
<td>第八组</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>添加 : 88，修改 : 729，删除 : 444</td>
<td>添加 : 9401，修改 : 78899，删除 : 47316</td>
</tr>
</tbody>
</table>
<h3 id="测试代码"><a href="#测试代码" class="headerlink" title="测试代码"></a>测试代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> org;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">import</span> java.sql.Connection;</span><br><span class="line"><span class="keyword">import</span> java.sql.DriverManager;</span><br><span class="line"><span class="keyword">import</span> java.sql.PreparedStatement;</span><br><span class="line"><span class="keyword">import</span> java.sql.SQLException;</span><br><span class="line"><span class="keyword">import</span> java.util.Calendar;</span><br><span class="line"> </span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">进行单机的myql压力测试</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>&#123;</span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Class.forName(<span class="string">"com.mysql.jdbc.Driver"</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (ClassNotFoundException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> times = <span class="number">10000</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a=<span class="number">0</span>;a&lt;<span class="number">3</span>;a++) &#123;</span><br><span class="line">            System.out.println(<span class="string">"第"</span>+a+<span class="string">"次"</span>+<span class="string">"次数："</span>+times);</span><br><span class="line">            System.out.println(<span class="string">"N,N,N"</span>);</span><br><span class="line">            method1();</span><br><span class="line">            System.out.println(<span class="string">"N,Y,N"</span>);</span><br><span class="line">            method2();</span><br><span class="line">            System.out.println(<span class="string">"Y,N,N"</span>);</span><br><span class="line">            method3();</span><br><span class="line">            System.out.println(<span class="string">"Y,Y,N"</span>);</span><br><span class="line">            method4();</span><br><span class="line">            System.out.println(<span class="string">"N,N,Y"</span>);</span><br><span class="line">            method8();</span><br><span class="line">            System.out.println(<span class="string">"N,Y,Y"</span>);</span><br><span class="line">            method6();</span><br><span class="line">            System.out.println(<span class="string">"Y,N,Y"</span>);</span><br><span class="line">            method7();</span><br><span class="line">            System.out.println(<span class="string">"Y,Y,Y"</span>);</span><br><span class="line">            method5();</span><br><span class="line">            System.out.println(<span class="string">"---------------------------------------------------------------"</span>);</span><br><span class="line">            times=times*<span class="number">10</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Connection <span class="title">tool</span><span class="params">(String data, String... args)</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        String url = <span class="string">"jdbc:mysql://127.0.0.1"</span> + <span class="string">"/"</span> + data;</span><br><span class="line">        String user = <span class="string">"root"</span>;</span><br><span class="line">        String password = <span class="string">"14159265jkl"</span>;</span><br><span class="line">        <span class="keyword">for</span> (String item : args) &#123;</span><br><span class="line">            url += <span class="string">"?"</span> + item;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> DriverManager.getConnection(url, user, password);</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">long</span> start = <span class="number">0</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">start</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        start = Calendar.getInstance().getTimeInMillis();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">end</span><span class="params">(String info)</span> </span>&#123;</span><br><span class="line">        System.out.println(info + <span class="string">" : "</span> + (Calendar.getInstance().getTimeInMillis() - start));</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不使用服务器预编译，不使用事物提交使用自动提交,不使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method1</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事物提交使用自动提交,不使用批处理-增加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事物提交使用自动提交,不使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事物提交使用自动提交,不使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不使用服务器预编译，使用事务提交,不使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method2</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,不使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,不使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,不使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        使用服务器预编译，不使用事务提交方法,不使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method3</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=true&amp;cachePrepStmts=true"</span>&#125;);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务提交方法,不使用批处理-增加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务提交方法,不使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务提交方法,不使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">       使用服务器预编译，使用事务提交方法,不使用批处理</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method4</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=true&amp;cachePrepStmts=true"</span>&#125;);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,不使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,不使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.execute();</span><br><span class="line">        &#125;</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,不使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        使用服务器预编译，使用事务，使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method5</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>&#125;);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，使用事务提交,使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不使用服务器预编译，使用事务，使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method6</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=false&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>&#125;);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        con.commit();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，使用事务提交,使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        使用服务器预编译，不使用事务，使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method7</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>&#125;);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务，使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务，使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"使用服务器预编译，不使用事务，使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不使用服务器预编译，不使用事务，使用批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method8</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        <span class="comment">//开起服务端预编译，开起预编译缓存，</span></span><br><span class="line">        Connection con = tool(<span class="string">"TestOther"</span>, <span class="keyword">new</span> String[]&#123;<span class="string">"useServerPrepStmts=false&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>&#125;);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事务，使用批处理-添加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事务，使用批处理-修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">            statement.addBatch();</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">10000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        statement.executeBatch();</span><br><span class="line">        end(<span class="string">"不使用服务器预编译，不使用事务，使用批处理-删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/jdbc驱动使用详解（四）流式读取/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/jdbc驱动使用详解（四）流式读取/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="java-jdbc驱动使用详解（四）流式读取"><a href="#java-jdbc驱动使用详解（四）流式读取" class="headerlink" title="java-jdbc驱动使用详解（四）流式读取"></a>java-jdbc驱动使用详解（四）流式读取</h2><p>mysql驱动默认的行为是需要把整个结果全部读取到内存中才开始允许应用读取结果，执行ResultSet的next方法是阻塞的，期望的方式是有数据就让人他返回，所以这里开发mysql的流式读取</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">PreparedStatement ps = connection.prepareStatement(<span class="string">"select .. from .."</span>, </span><br><span class="line">            ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); </span><br><span class="line"> </span><br><span class="line"><span class="comment">//forward only read only也是mysql 驱动的默认值，所以不指定也是可以的 比如： PreparedStatement ps = connection.prepareStatement("select .. from .."); </span></span><br><span class="line"> </span><br><span class="line">ps.setFetchSize(Integer.MIN_VALUE); <span class="comment">//也可以修改jdbc url通过defaultFetchSize参数来设置，这样默认所以的返回结果都是通过流方式读取.</span></span><br><span class="line">ResultSet rs = ps.executeQuery(); </span><br><span class="line"> </span><br><span class="line"><span class="keyword">while</span> (rs.next()) &#123; </span><br><span class="line">　　System.out.println(rs.getString(<span class="string">"fieldName"</span>)); </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>mysql判断是否开启流式读取结果的方法，有三个条件forward-only，read-only，fatch size是Integer.MIN_VALUE</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/junit4使用整理(一)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/junit4使用整理(一)/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <blockquote>
<p>最用在企业中进行实习使用了junit4进行单元测试这里进行一下相关的知识点的总结</p>
</blockquote>
<h3 id="JUnit是什么"><a href="#JUnit是什么" class="headerlink" title="JUnit是什么"></a>JUnit是什么</h3><p>JUnit是用于编写和运行可重复的自动化测试的开源测试框架， 这样可以保证我们的代码按预期工作。JUnit可广泛用于工业和作为支架(从命令行)或IDE(如Eclipse)内单独的Java程序。</p>
<h4 id="JUnit的提供"><a href="#JUnit的提供" class="headerlink" title="JUnit的提供"></a>JUnit的提供</h4><ul>
<li>断言测试预期结果。</li>
<li>测试功能共享通用的测试数据。</li>
<li>测试套件轻松地组织和运行测试。</li>
<li>图形和文本测试运行。</li>
</ul>
<h4 id="JUnit用于测试"><a href="#JUnit用于测试" class="headerlink" title="JUnit用于测试"></a>JUnit用于测试</h4><ul>
<li>整个对象</li>
<li>对象的一部分 – 交互的方法或一些方法</li>
<li>几个对象之间的互动(交互)</li>
</ul>
<h4 id="JUnit的特点"><a href="#JUnit的特点" class="headerlink" title="JUnit的特点"></a>JUnit的特点</h4><ul>
<li>JUnit是用于编写和运行测试的开源框架。</li>
<li>提供了注释，以确定测试方法。</li>
<li>提供断言测试预期结果。</li>
<li>提供了测试运行的运行测试。</li>
<li>JUnit测试让您可以更快地编写代码，提高质量</li>
<li>JUnit是优雅简洁。它是不那么复杂以及不需要花费太多的时间。</li>
<li>JUnit测试可以自动运行，检查自己的结果，并提供即时反馈。没有必要通过测试结果报告来手动梳理。</li>
<li>JUnit测试可以组织成测试套件包含测试案例，甚至其他测试套件。</li>
<li>Junit显示测试进度的，如果测试是没有问题条形是绿色的，测试失败则会变成红色。</li>
</ul>
<h4 id="junit4简单例子"><a href="#junit4简单例子" class="headerlink" title="junit4简单例子"></a>junit4简单例子</h4><ol>
<li>新建一个测试类</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ItemDemo</span> </span>&#123;</span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">sum</span><span class="params">(<span class="keyword">int</span> a,<span class="keyword">int</span> b)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> a+b;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>创建一个测试类</li>
</ol>
<blockquote>
<p>过程：指定一个测试用的工具包右键&gt;&gt;new&gt;&gt;other&gt;&gt;搜索junit&gt;&gt;选择 Junit Test Case</p>
</blockquote>
<p><img src="blogimg/junit/1.png" alt=""></p>
<p><img src="blogimg/junit/2.png" alt=""></p>
<p>创建后的类</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.junit.Assert.*;</span><br><span class="line"><span class="keyword">import</span> org.junit.Test;</span><br><span class="line"><span class="keyword">import</span> a_baseForJava.a_junit4.main.ItemDemo;</span><br><span class="line">public class ItemTest &#123; &lt;span&gt; &lt;/span&gt;@Test &lt;span&gt; &lt;/span&gt;public void testSum() &#123; &lt;span&gt; &lt;/span&gt;ItemDemo sum = new ItemDemo(); &lt;span&gt; &lt;/span&gt;assertEquals(sum.sum(10,12), 22); &lt;span&gt; &lt;/span&gt;&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="3">
<li>进行测试</li>
</ol>
<blockquote>
<p>右键&gt;&gt;run as Test</p>
</blockquote>
<p><img src="blogimg/junit/3.png" alt=""></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/java函数式编程（一）Optional/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/java函数式编程（一）Optional/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/junit4使用整理（三）spring整合/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/junit4使用整理（三）spring整合/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <blockquote>
<p>这里记录一下spring 和 junit4进行整合例子</p>
</blockquote>
<p>现在情况下spring支持的junit版本不是很高 使用junit4.1.2进行开发</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> javax.annotation.Resource;</span><br><span class="line"><span class="keyword">import</span> org.junit.Test;</span><br><span class="line"><span class="keyword">import</span> org.junit.runner.RunWith;</span><br><span class="line"><span class="keyword">import</span> org.springframework.beans.BeansException;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.ApplicationContext;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.ApplicationContextAware;</span><br><span class="line"><span class="keyword">import</span> org.springframework.test.annotation.Rollback;</span><br><span class="line"><span class="keyword">import</span> org.springframework.test.context.ContextConfiguration;</span><br><span class="line"><span class="keyword">import</span> org.springframework.test.context.junit4.SpringJUnit4ClassRunner;</span><br><span class="line"><span class="keyword">import</span> org.springframework.transaction.annotation.Transactional;</span><br><span class="line"><span class="keyword">import</span> b_spring.a_spring的bean的依赖注入.bean.DemoBeanOne;</span><br><span class="line"><span class="meta">@RunWith</span>(SpringJUnit4ClassRunner.class)</span><br><span class="line"><span class="meta">@ContextConfiguration</span>(locations =&#123;<span class="string">"classpath:a_bean.xml"</span>&#125;)</span><br><span class="line"><span class="meta">@Transactional</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestForOneMain</span> <span class="keyword">implements</span> <span class="title">ApplicationContextAware</span></span>&#123;</span><br><span class="line">	ApplicationContext context;</span><br><span class="line">	<span class="meta">@Resource</span>(name=<span class="string">"demoOne"</span>)</span><br><span class="line">	DemoBeanOne demoBeanOne;</span><br><span class="line">	<span class="meta">@Test</span></span><br><span class="line">	<span class="meta">@Transactional</span><span class="comment">//指定可以进行事物</span></span><br><span class="line">	<span class="meta">@Rollback</span>(value=<span class="keyword">true</span>)<span class="comment">//声明事物操作</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">test</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setApplicationContext</span><span class="params">(ApplicationContext applicationContext)</span> <span class="keyword">throws</span> BeansException </span>&#123;</span><br><span class="line">		<span class="comment">// TODO Auto-generated method stub</span></span><br><span class="line">		<span class="keyword">this</span>.context=applicationContext;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>@RunWith：用于指定junit运行环境，是junit提供给其他框架测试环境接口扩展，为了便于使用spring的依赖注入，spring提供了org.springframework.test.context.junit4.SpringJUnit4ClassRunner作为Junit测试环境</li>
<li>@ContextConfiguration({“classpath:applicationContext.xml”,”classpath:spring/buyer/applicationContext-service.xml”}) 导入配置文件，这里我的applicationContext配置文件是根据模块来分类的。如果有多个模块就引入多个“applicationContext-service.xml”文件。如果所有的都是写在“applicationContext。xml”中则这样导入</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/java-注解反射动态代理-反射/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/java-注解反射动态代理-反射/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="反射的定义"><a href="#反射的定义" class="headerlink" title="反射的定义"></a>反射的定义</h2><p>在运行状态中，对于任意一个类，都能够知道这个类的所有属性和方法；对于任意一个对象，都能够调用它的任意一个方法和属性；这种动态获取的信息以及动态调用对象的方法的功能称为反射。</p>
<p>在java中反射是基于class信息的</p>
<blockquote>
<p>关于Class</p>
</blockquote>
<ol>
<li><p>Class是一个类，一个描述类的类（也就是描述类本身），封装了描述方法的Method，描述字段的Filed，描述构造器的Constructor等属性</p>
</li>
<li><p>对象照镜子后（反射）可以得到的信息：某个类的数据成员名、方法和构造器、某个类到底实现了哪些接口。</p>
</li>
<li><p>对于每个类而言，JRE 都为其保留一个不变的 Class 类型的对象。一个 Class 对象包含了特定某个类的有关信息。</p>
</li>
<li><p>Class 对象只能由系统建立对象</p>
</li>
<li><p>一个类在 JVM 中只会有一个Class实例</p>
</li>
</ol>
<h2 id="java-通过编程方法应用反射特性"><a href="#java-通过编程方法应用反射特性" class="headerlink" title="java 通过编程方法应用反射特性"></a>java 通过编程方法应用反射特性</h2><h3 id="1-获取类的方法"><a href="#1-获取类的方法" class="headerlink" title="1. 获取类的方法"></a>1. 获取类的方法</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//使用对象获取Class</span></span><br><span class="line">Class&lt;?&gt; itemClass = <span class="keyword">new</span> String().getClass();</span><br><span class="line"><span class="comment">//直接使用类名.class获取</span></span><br><span class="line">Class&lt;?&gt; itemClass2 = String.class;</span><br><span class="line"><span class="comment">//使用类的完整路径获取</span></span><br><span class="line">Class&lt;?&gt; itemClass3 = Class.forName(<span class="string">"java.lang.String"</span>);</span><br><span class="line"><span class="comment">//获取父类</span></span><br><span class="line">Class&lt;?&gt; fatherClass = itemClass.getSuperClass();</span><br></pre></td></tr></table></figure>
<h3 id="2-使用class类"><a href="#2-使用class类" class="headerlink" title="2. 使用class类"></a>2. 使用class类</h3><blockquote>
<p>使用newInstance生成对象</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">String string= (String) itemClass.newInstance();</span><br></pre></td></tr></table></figure>
<blockquote>
<p>使用构造方法生成对象</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Constructor&lt;?&gt; constructor = itemClass.getConstructor(Integer.class,String.class);</span><br><span class="line"><span class="comment">//返回这个class所含有的所有方法--不包括继承的方法--只能使用自己定义的构造方法</span></span><br><span class="line">Constructor&lt;?&gt;[] constructors = itemClass.getConstructors();</span><br><span class="line">constructor.newInstance(<span class="number">12</span>,<span class="string">"sf"</span>);</span><br></pre></td></tr></table></figure>
<blockquote>
<p>其他用法</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//--返回成员枚举类型 如果不是枚举类型返回 null</span></span><br><span class="line">class1.getEnumConstants();</span><br><span class="line"><span class="comment">//---class 类强制转化方法</span></span><br><span class="line">class1.asSubclass(class2);<span class="comment">//将class1转化成class2</span></span><br><span class="line">class1.cast(i);<span class="comment">// 讲 i强制转化成 class1所表示的实现类</span></span><br><span class="line"><span class="comment">//获得classloader</span></span><br><span class="line">ClassLoader acClassLoader = class1.getClassLoader();</span><br><span class="line">Class&lt;?&gt;[] classes=class2.getInterfaces();<span class="comment">//获得接口数组</span></span><br><span class="line">String string = class1.getName();<span class="comment">//返回类名称</span></span><br><span class="line">Package string2 =class1.getPackage();<span class="comment">//返回变量的包类</span></span><br><span class="line">URL rUrl = class1.getResource(<span class="string">"xx"</span>);<span class="comment">//返回给定名称所属的资源</span></span><br><span class="line">InputStream string3 = class1.getResourceAsStream(<span class="string">"xxx"</span>);<span class="comment">//将给定的资源变成输入流</span></span><br></pre></td></tr></table></figure>
<h3 id="使用反射获取类加载器"><a href="#使用反射获取类加载器" class="headerlink" title="使用反射获取类加载器"></a>使用反射获取类加载器</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1、获取一个系统的类加载器</span></span><br><span class="line">ClassLoader classLoader = ClassLoader.getSystemClassLoader();</span><br><span class="line">System.out.println(<span class="string">"系统的类加载器--&gt;"</span> + classLoader);</span><br><span class="line"></span><br><span class="line"><span class="comment">//2、获取系统类加载器的父类加载器(扩展类加载器（extensions classLoader）)</span></span><br><span class="line">classLoader = classLoader.getParent();</span><br><span class="line">System.out.println(<span class="string">"扩展类加载器--&gt;"</span> + classLoader);</span><br><span class="line"></span><br><span class="line"><span class="comment">//3、获取扩展类加载器的父类加载器</span></span><br><span class="line"><span class="comment">//输出为Null,无法被Java程序直接引用</span></span><br><span class="line">classLoader = classLoader.getParent();</span><br><span class="line">System.out.println(<span class="string">"启动类加载器--&gt;"</span> + classLoader);</span><br><span class="line"></span><br><span class="line"><span class="comment">//4、测试当前类由哪个类加载器进行加载 ,结果就是系统的类加载器</span></span><br><span class="line">classLoader = Class.forName(<span class="string">"com.kys.test.InvokeTest"</span>).getClassLoader();</span><br><span class="line">System.out.println(<span class="string">"当前类由哪个类加载器进行加载--&gt;"</span>+classLoader);</span><br><span class="line"></span><br><span class="line"><span class="comment">//5、测试JDK提供的Object类由哪个类加载器负责加载的</span></span><br><span class="line">classLoader = Class.forName(<span class="string">"java.lang.Object"</span>).getClassLoader();</span><br><span class="line">System.out.println(<span class="string">"JDK提供的Object类由哪个类加载器加载--&gt;"</span> + classLoader);</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#输出</span><br><span class="line">系统的类加载器--&gt;sun.misc.Launcher$AppClassLoader@<span class="number">18</span>b4aac2</span><br><span class="line">扩展类加载器--&gt;sun.misc.Launcher$ExtClassLoader@<span class="number">61</span>bbe9ba</span><br><span class="line">启动类加载器--&gt;<span class="keyword">null</span></span><br><span class="line">当前类由哪个类加载器进行加载--&gt;sun.misc.Launcher$AppClassLoader@<span class="number">18</span>b4aac2</span><br><span class="line">JDK提供的Object类由哪个类加载器加载--&gt;<span class="keyword">null</span></span><br></pre></td></tr></table></figure>
<h3 id="引申使用class-类获取资源"><a href="#引申使用class-类获取资源" class="headerlink" title="引申使用class 类获取资源"></a>引申使用class 类获取资源</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// /(左划线)表示使用classpath根目录进行下过关属性的查找</span></span><br><span class="line">TestRelativePath.class.getResource(“/test.txt”).getFile()</span><br><span class="line">Thread.currentThread().getContextClassLoader().getResource(“test.txt”).getFile()</span><br></pre></td></tr></table></figure>
<h3 id="method-获取类中的方法"><a href="#method-获取类中的方法" class="headerlink" title="method 获取类中的方法"></a>method 获取类中的方法</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//返回名称为xx参数为后面的变长数组的 直接成员方法</span></span><br><span class="line">Method method = class1.getDeclaredMethod(<span class="string">"xx"</span>, Integer.class);</span><br><span class="line"><span class="comment">//方法处理继承的方法</span></span><br><span class="line">Method method2 = class1.getMethod(<span class="string">"x"</span>, Integer.class);</span><br><span class="line">Annotation[][] annotations = method.getParameterAnnotations();<span class="comment">//返回一个注解的二维数组 --同上面</span></span><br><span class="line">Annotation[] annotations2=method.getAnnotations();</span><br><span class="line">Class&lt;?&gt;[] class3 = method.getParameterTypes();<span class="comment">//返回参数数组</span></span><br><span class="line">Class&lt;?&gt; class4 = method.getReturnType();<span class="comment">//返回返回值数组</span></span><br><span class="line"><span class="keyword">int</span> count=method.getParameterCount();<span class="comment">//返回参数的数量</span></span><br><span class="line">Parameter[] parameters=method.getParameters();<span class="comment">//返回参数列表</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">c</span> </span>= method.getDeclaringClass();<span class="comment">//返回这个方法对应的class类</span></span><br><span class="line">parameters[<span class="number">0</span>].getName();</span><br><span class="line">parameters[<span class="number">0</span>].getType();<span class="comment">//返回类型的class数组</span></span><br><span class="line"><span class="comment">//参数类型没有注入 参数</span></span><br><span class="line">method.invoke(<span class="keyword">new</span> ThisisCeshe(), <span class="keyword">null</span>);<span class="comment">//类似 FIeld的get方法--调用指定的实例的一个此method指定的方法</span></span><br></pre></td></tr></table></figure>
<h3 id="Field字段"><a href="#Field字段" class="headerlink" title="Field字段"></a>Field字段</h3><p>field 相关方法</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//--成员变量</span></span><br><span class="line">Field field =class1.getDeclaredField(<span class="string">"xixi"</span>);<span class="comment">//返回变量名称为 field 的直接成员变量名称</span></span><br><span class="line">Field field2= class1.getField(<span class="string">"xxixi"</span>);<span class="comment">//返回变量名称包括父元素的成员变量</span></span><br><span class="line"><span class="comment">//f ye e d</span></span><br><span class="line">Field[] fields=class1.getDeclaredFields();<span class="comment">//返回所有直接的成员变量</span></span><br><span class="line">Field[] fields2 = class1.getFields();<span class="comment">//返回所有的成员变量 包括父类进行继承的变量</span></span><br><span class="line">field.get(<span class="keyword">new</span> ThisisCeshe());<span class="comment">//返回object 传入一个得出field对象的class的实例才能对其使用 取出实例中的对应的field对象 --存在基本类型的那一坨方法</span></span><br><span class="line">field.getType();<span class="comment">//返回一个class 对象表明这个字段的类型</span></span><br><span class="line">field.getName();<span class="comment">//返回这个字段的名字</span></span><br><span class="line">field.set(<span class="keyword">new</span> Integer(<span class="number">12</span>), <span class="number">123</span>);<span class="comment">//在前一个对象中 加入 后一个变量到field指定的变量上 --存在基本类型的那一坨方法</span></span><br><span class="line"><span class="keyword">int</span> a=field.getModifiers();<span class="comment">//返回参数类型--public或者其他</span></span><br></pre></td></tr></table></figure>
<h3 id="Annotated字段"><a href="#Annotated字段" class="headerlink" title="Annotated字段"></a>Annotated字段</h3><p>所有继承和实现了AnnotatedElement接口的类都具有返回对应的接口信息的方法，比如class method feild constructor</p>
<blockquote>
<p>注意下面的代码 *** 表示全部的反射都支持，特殊情况使用||分割</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Target Target = ***.getAnnotation(Target.class);<span class="comment">//返回当前类中是否存在传入的注解 有的时候将会进行返回相应的注解</span></span><br><span class="line">***.isAnnotationPresent(Ceshi2.class);<span class="comment">//判断是否存在一个注解</span></span><br><span class="line">Annotation[] annotations = ***.getAnnotations();<span class="comment">//返回类中所有的注解包括继承的</span></span><br><span class="line">Annotation[] annotations2= ***.getDeclaredAnnotations();<span class="comment">//f返回类中直接继承的元素</span></span><br></pre></td></tr></table></figure>
<p>注解的用法</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">Annotation[][] annotation = constructor.getParameterAnnotations();</span><br><span class="line"><span class="comment">//所使用类型判断 强制转换</span></span><br><span class="line"><span class="keyword">if</span>(annotation[<span class="number">0</span>][<span class="number">0</span>] <span class="keyword">instanceof</span> Target)&#123;</span><br><span class="line">    Target targets= (Target) annotation[<span class="number">0</span>][<span class="number">0</span>];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//直接获取直接使用</span></span><br><span class="line">Target annotation = ***.getAnnotation(Target.class);</span><br></pre></td></tr></table></figure>
<h3 id="特殊的enclose-方法"><a href="#特殊的enclose-方法" class="headerlink" title="特殊的enclose* 方法"></a>特殊的enclose* 方法</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.kys.test;</span><br><span class="line"><span class="keyword">import</span> java.lang.annotation.Annotation;</span><br><span class="line"><span class="keyword">import</span> java.lang.reflect.AnnotatedElement;</span><br><span class="line"><span class="keyword">import</span> java.lang.reflect.Constructor;</span><br><span class="line"><span class="keyword">import</span> java.lang.reflect.Method;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Outer</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Outer</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 构造方法中的匿名内部类</span></span><br><span class="line">        InnerClass innerClass = <span class="keyword">new</span> InnerClass() &#123;</span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">fun</span><span class="params">()</span> </span>&#123;</span><br><span class="line">                getEnclosing(<span class="keyword">this</span>.getClass());</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;;</span><br><span class="line">        innerClass.fun();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 匿名内部类</span></span><br><span class="line">    <span class="keyword">static</span> InnerClass innerClass = <span class="keyword">new</span> InnerClass() &#123;</span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">fun</span><span class="params">()</span> </span>&#123;</span><br><span class="line">            getEnclosing(<span class="keyword">this</span>.getClass());</span><br><span class="line">            <span class="comment">/**</span></span><br><span class="line"><span class="comment">             * enclosingClass=class reflect.Outer</span></span><br><span class="line"><span class="comment">             * enclosingConstructor=null</span></span><br><span class="line"><span class="comment">             * enclosingMethod=null</span></span><br><span class="line"><span class="comment">             */</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">test</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="comment">// 方法中的匿名内部类</span></span><br><span class="line">        InnerClass innerClass = <span class="keyword">new</span> InnerClass() &#123;</span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">fun</span><span class="params">()</span> </span>&#123;</span><br><span class="line">                getEnclosing(<span class="keyword">this</span>.getClass());</span><br><span class="line">                <span class="comment">/**</span></span><br><span class="line"><span class="comment">                 * enclosingClass=class reflect.Outer</span></span><br><span class="line"><span class="comment">                 * enclosingConstructor=null</span></span><br><span class="line"><span class="comment">                 * enclosingMethod=public static void reflect.Outer.test()</span></span><br><span class="line"><span class="comment">                 */</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;;</span><br><span class="line">        innerClass.fun();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 内部类</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">InnerClass</span> </span>&#123;</span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="title">InnerClass</span><span class="params">()</span> </span>&#123;&#125;</span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">fun</span><span class="params">()</span> </span>&#123;&#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"------内部类------"</span>);</span><br><span class="line">        getEnclosing(InnerClass.class);</span><br><span class="line"></span><br><span class="line">        System.out.println(<span class="string">"------匿名内部类------"</span>);</span><br><span class="line">        innerClass.fun();</span><br><span class="line"></span><br><span class="line">        System.out.println(<span class="string">"------方法中的匿名内部类------"</span>);</span><br><span class="line">        Outer.test();</span><br><span class="line"></span><br><span class="line">        System.out.println(<span class="string">"------构造函数中的匿名内部类------"</span>);</span><br><span class="line">        <span class="keyword">new</span> Outer();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * getEnclosingClass:该类是在那个类中定义的， 比如直接定义的内部类或匿名内部类</span></span><br><span class="line"><span class="comment">     * getEnclosingConstructor：该类是在哪个构造函数中定义的，比如构造方法中定义的匿名内部类</span></span><br><span class="line"><span class="comment">     * getEnclosingMethod：该类是在哪个方法中定义的，比如方法中定义的匿名内部类</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> cls</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">getEnclosing</span><span class="params">(Class cls)</span> </span>&#123;</span><br><span class="line">        Class enclosingClass = cls.getEnclosingClass();</span><br><span class="line">        Constructor enclosingConstructor = cls.getEnclosingConstructor();</span><br><span class="line">        Method enclosingMethod = cls.getEnclosingMethod();</span><br><span class="line">        System.out.println(<span class="string">"enclosingClass="</span> + enclosingClass);</span><br><span class="line">        System.out.println(<span class="string">"enclosingConstructor="</span> + enclosingConstructor);</span><br><span class="line">        System.out.println(<span class="string">"enclosingMethod="</span> + enclosingMethod);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这个方法是针对内部类的，如果这个class是一个内部类通过这个方法可以得出这个内部类对应的声明位置</p>
<h3 id="array-范型"><a href="#array-范型" class="headerlink" title="array 范型"></a>array 范型</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//创建一个第二个参数是边长参数的组 第一个参数是指定类型的数组</span></span><br><span class="line">Array[][] arrays=(Array[][]) Array.newInstance(Integer.class, <span class="number">100</span>,<span class="number">100</span>);</span><br><span class="line">Array.get(arrays, <span class="number">0</span>);<span class="comment">//返回制定对象索引的值 注意只能返回一维 并且返回的对象是object类型---相关  函数还有getint等基本类型</span></span><br><span class="line">Array.set(arrays, <span class="number">0</span>, <span class="keyword">new</span> Integer(<span class="number">12</span>));<span class="comment">//将指定的类型传递到数组指定的位置中</span></span><br></pre></td></tr></table></figure>
<h3 id="AccessibleObject"><a href="#AccessibleObject" class="headerlink" title="AccessibleObject"></a>AccessibleObject</h3><blockquote>
<p>AccessibleObject是 Method Fielt Construction的一个父类-都实现了此类的方法,这个类主要是扩展了访问权限的控制</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">AccessibleObject accessibleObject = <span class="keyword">null</span>;</span><br><span class="line">accessibleObject.isAnnotationPresent(hehehe.class);<span class="comment">//判断这个类是否实现了hehehe这个接口</span></span><br><span class="line">accessibleObject.getAnnotation(hehehe.class);</span><br><span class="line">accessibleObject.getAnnotations();</span><br><span class="line"><span class="comment">//!!!---设置当前东西的访问性--- 设置为true的时候将可以实现对私有变量的  该便似有变量和成员的访问性</span></span><br><span class="line">accessibleObject.setAccessible(<span class="keyword">true</span>);</span><br></pre></td></tr></table></figure>
<p>尤其要注意这个地方setAccessible(true); 正是通过这个配置方法的访问权限</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/jdbc驱动使用详解（三）单机分库分表下的性能测试/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/jdbc驱动使用详解（三）单机分库分表下的性能测试/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="java-jdbc驱动使用详解（三）单机分库分表下的性能测试"><a href="#java-jdbc驱动使用详解（三）单机分库分表下的性能测试" class="headerlink" title="java-jdbc驱动使用详解（三）单机分库分表下的性能测试"></a>java-jdbc驱动使用详解（三）单机分库分表下的性能测试</h2><p>上一篇进行过测试，批处理和事务提交结合，可以显著的提升数据库增删改操作的性能，但是有一个问题——在多表和多数据库情况下使用多线程编程性能会提升多少。为了解决这个问题进行了如下的测试</p>
<h3 id="测试代码"><a href="#测试代码" class="headerlink" title="测试代码"></a>测试代码</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br><span class="line">462</span><br><span class="line">463</span><br><span class="line">464</span><br><span class="line">465</span><br><span class="line">466</span><br><span class="line">467</span><br><span class="line">468</span><br><span class="line">469</span><br><span class="line">470</span><br><span class="line">471</span><br><span class="line">472</span><br><span class="line">473</span><br><span class="line">474</span><br><span class="line">475</span><br><span class="line">476</span><br><span class="line">477</span><br><span class="line">478</span><br><span class="line">479</span><br><span class="line">480</span><br><span class="line">481</span><br><span class="line">482</span><br><span class="line">483</span><br><span class="line">484</span><br><span class="line">485</span><br><span class="line">486</span><br><span class="line">487</span><br><span class="line">488</span><br><span class="line">489</span><br><span class="line">490</span><br><span class="line">491</span><br><span class="line">492</span><br><span class="line">493</span><br><span class="line">494</span><br><span class="line">495</span><br><span class="line">496</span><br><span class="line">497</span><br><span class="line">498</span><br><span class="line">499</span><br><span class="line">500</span><br><span class="line">501</span><br><span class="line">502</span><br><span class="line">503</span><br><span class="line">504</span><br><span class="line">505</span><br><span class="line">506</span><br><span class="line">507</span><br><span class="line">508</span><br><span class="line">509</span><br><span class="line">510</span><br><span class="line">511</span><br><span class="line">512</span><br><span class="line">513</span><br><span class="line">514</span><br><span class="line">515</span><br><span class="line">516</span><br><span class="line">517</span><br><span class="line">518</span><br><span class="line">519</span><br><span class="line">520</span><br><span class="line">521</span><br><span class="line">522</span><br><span class="line">523</span><br><span class="line">524</span><br><span class="line">525</span><br><span class="line">526</span><br><span class="line">527</span><br><span class="line">528</span><br><span class="line">529</span><br><span class="line">530</span><br><span class="line">531</span><br><span class="line">532</span><br><span class="line">533</span><br><span class="line">534</span><br><span class="line">535</span><br><span class="line">536</span><br><span class="line">537</span><br><span class="line">538</span><br><span class="line">539</span><br><span class="line">540</span><br><span class="line">541</span><br><span class="line">542</span><br><span class="line">543</span><br><span class="line">544</span><br><span class="line">545</span><br><span class="line">546</span><br><span class="line">547</span><br><span class="line">548</span><br><span class="line">549</span><br><span class="line">550</span><br><span class="line">551</span><br><span class="line">552</span><br><span class="line">553</span><br><span class="line">554</span><br><span class="line">555</span><br><span class="line">556</span><br><span class="line">557</span><br><span class="line">558</span><br><span class="line">559</span><br><span class="line">560</span><br><span class="line">561</span><br><span class="line">562</span><br><span class="line">563</span><br><span class="line">564</span><br><span class="line">565</span><br><span class="line">566</span><br><span class="line">567</span><br><span class="line">568</span><br><span class="line">569</span><br><span class="line">570</span><br><span class="line">571</span><br><span class="line">572</span><br><span class="line">573</span><br><span class="line">574</span><br><span class="line">575</span><br><span class="line">576</span><br><span class="line">577</span><br><span class="line">578</span><br><span class="line">579</span><br><span class="line">580</span><br><span class="line">581</span><br><span class="line">582</span><br><span class="line">583</span><br><span class="line">584</span><br><span class="line">585</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> org;</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="keyword">import</span> java.sql.Connection;</span><br><span class="line"><span class="keyword">import</span> java.sql.DriverManager;</span><br><span class="line"><span class="keyword">import</span> java.sql.PreparedStatement;</span><br><span class="line"><span class="keyword">import</span> java.sql.SQLException;</span><br><span class="line"><span class="keyword">import</span> java.util.Calendar;</span><br><span class="line"><span class="keyword">import</span> java.util.concurrent.atomic.AtomicInteger;</span><br><span class="line"> </span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">    测试同库不同表和不同库不同表的性能之间的差别</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MainT</span> </span>&#123;</span><br><span class="line">    <span class="keyword">static</span> AtomicInteger atomicInteger = <span class="keyword">new</span> AtomicInteger(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">ExecuteThread</span> <span class="keyword">extends</span> <span class="title">Thread</span> </span>&#123;</span><br><span class="line">        PreparedStatement preparedStatement;</span><br><span class="line">        Connection connection;</span><br><span class="line"> </span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="title">ExecuteThread</span><span class="params">(PreparedStatement statement, Connection connection)</span> </span>&#123;</span><br><span class="line">            <span class="keyword">this</span>.preparedStatement = statement;</span><br><span class="line">            <span class="keyword">this</span>.connection = connection;</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                preparedStatement.executeBatch();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                connection.commit();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">            atomicInteger.addAndGet(<span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Class.forName(<span class="string">"com.mysql.jdbc.Driver"</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (ClassNotFoundException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> times = <span class="number">1000000</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        method1();</span><br><span class="line">        method2();</span><br><span class="line">        method3();</span><br><span class="line">        <span class="comment">//method4();</span></span><br><span class="line">        <span class="comment">//method5();</span></span><br><span class="line">        <span class="comment">//method6();</span></span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">long</span> time = <span class="number">0</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">start</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        time = Calendar.getInstance().getTimeInMillis();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">end</span><span class="params">(String string)</span> </span>&#123;</span><br><span class="line">        System.out.println(string + <span class="string">" "</span> + <span class="string">"time is:"</span> + (Calendar.getInstance().getTimeInMillis() - time));</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        同数据库 多练接 事务批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method1</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(<span class="string">"jdbc:mysql://127.0.0.1:3306/TestOther?useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>, <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        Connection con2 = DriverManager.getConnection(<span class="string">"jdbc:mysql://127.0.0.1:3306/TestOther?useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>, <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        con2.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con2.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"同数据库 多练接 事务批处理:增加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        statement2 = con2.prepareStatement(<span class="string">"update tbtwo SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">"同数据库 多练接 事务批处理:修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        statement2 = con2.prepareStatement(<span class="string">"delete FROM tbtwo where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"同数据库 多练接 事务批处理:删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">            不同数据库 多练接 事务批处理</span></span><br><span class="line"><span class="comment">         */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method2</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(<span class="string">"jdbc:mysql://127.0.0.1:3306/TestOne?useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>, <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        Connection con2 = DriverManager.getConnection(<span class="string">"jdbc:mysql://127.0.0.1:3306/TestTwo?useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>, <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        con2.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con2.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"不同数据库 多练接 事务批处理:增加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        statement2 = con2.prepareStatement(<span class="string">"update tbtwo SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">"不同数据库 多练接 事务批处理:修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        statement2 = con2.prepareStatement(<span class="string">"delete FROM tbtwo where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con2).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"不同数据库 多练接 事务批处理:删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">     * 同数据库 单练接 事务批处理</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method3</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestOther?useServerPrepStmts=true&amp;cachePrepStmts=true&amp;rewriteBatchedStatements=true"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        con.setAutoCommit(<span class="keyword">false</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"同数据库 单练接 事务批处理:增加"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        statement2 = con.prepareStatement(<span class="string">"update tbtwo SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">"同数据库 单练接 事务批处理:修改"</span>);</span><br><span class="line">        statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">        statement2 = con.prepareStatement(<span class="string">"delete FROM tbtwo where id=?"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement.addBatch();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                statement2.addBatch();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">200000</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement.executeBatch();</span><br><span class="line">                statement2.executeBatch();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement, con).start();</span><br><span class="line">        <span class="keyword">new</span> ExecuteThread(statement2, con).start();</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == <span class="number">2</span>) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"同数据库 单练接 事务批处理:修改"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不同数据库 单链接 事务批处理</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="comment">//不存在</span></span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        不同数据库，多链接，非批处理</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">ExecuteThread2</span> <span class="keyword">extends</span> <span class="title">Thread</span> </span>&#123;</span><br><span class="line">        <span class="keyword">public</span> PreparedStatement statement;</span><br><span class="line"> </span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="title">ExecuteThread2</span><span class="params">(PreparedStatement statement)</span> </span>&#123;</span><br><span class="line">            <span class="keyword">this</span>.statement = statement;</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>&#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line"> </span><br><span class="line">                <span class="keyword">this</span>.statement.execute();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">                System.out.println(<span class="keyword">this</span>.statement);</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">            atomicInteger.addAndGet(<span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method4</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestOne"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        Connection con2 = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestTwo"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con2.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">" 不同数据库，多链接，非批处理:增加"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"update tbtwo SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">" 不同数据库，多链接，非批处理:修改"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"delete FROM tbtwo where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">" 不同数据库，多链接，非批处理:删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">    *   同数据库 单链接 非批处理</span></span><br><span class="line"><span class="comment">    * */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method5</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestOne"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">" 同数据库 单链接 非批处理:增加"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">" 同数据库 单链接 非批处理:修改"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">" 同数据库 单链接 非批处理:删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">    *   同数据库 多链接 非批处理</span></span><br><span class="line"><span class="comment">    * */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">method6</span><span class="params">()</span> <span class="keyword">throws</span> SQLException </span>&#123;</span><br><span class="line">        Connection con = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestOther"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        Connection con2 = DriverManager.getConnection(</span><br><span class="line">                <span class="string">"jdbc:mysql://127.0.0.1:3306/TestOther"</span>,</span><br><span class="line">                <span class="string">"root"</span>, <span class="string">"14159265jkl"</span>);</span><br><span class="line">        PreparedStatement statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        PreparedStatement statement2 = con2.prepareStatement(<span class="string">"insert into tbtwo(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"insert into tbone(id,name,password) values(?,'a','b')"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"  同数据库 多链接 非批处理:增加"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"update tbone SET name='aa',password='bb' where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line"> </span><br><span class="line">        end(<span class="string">"  同数据库 多链接 非批处理:修改"</span>);</span><br><span class="line">        start();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> a = <span class="number">0</span>; a &lt; times; a++) &#123;</span><br><span class="line">            <span class="keyword">if</span> (a % <span class="number">2</span> == <span class="number">0</span>) &#123;</span><br><span class="line">                statement = con.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">                statement.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement).start();</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                statement2 = con2.prepareStatement(<span class="string">"delete FROM tbone where id=?"</span>);</span><br><span class="line">                statement2.setInt(<span class="number">1</span>, a);</span><br><span class="line">                <span class="keyword">new</span> ExecuteThread2(statement2).start();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">while</span> (<span class="keyword">true</span>) &#123;</span><br><span class="line">            <span class="keyword">if</span> (atomicInteger.getAndAdd(<span class="number">0</span>) == times) &#123;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        atomicInteger.set(<span class="number">0</span>);</span><br><span class="line">        end(<span class="string">"  同数据库 多链接 非批处理:删除"</span>);</span><br><span class="line">        statement.close();</span><br><span class="line">        statement2.close();</span><br><span class="line">        con.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="测试样例和结果"><a href="#测试样例和结果" class="headerlink" title="测试样例和结果"></a>测试样例和结果</h3><table>
<thead>
<tr>
<th>组号</th>
<th>是否是同一个数据库</th>
<th>是否使用多个链接</th>
<th>是否使用批处理方法</th>
<th>1w（毫秒）</th>
<th>100w（毫秒）</th>
</tr>
</thead>
<tbody>
<tr>
<td>第一组</td>
<td>Y</td>
<td>N</td>
<td>N</td>
<td>添加 :42306，修改 :43521，删除 :44073</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第二组</td>
<td>N</td>
<td>Y</td>
<td>N</td>
<td>添加 : 34137，修改 : 34215，删除 : 33698</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第三组</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
<td>添加 : 34511，修改 : 34060，删除 : 33970</td>
<td>大于一小时</td>
</tr>
<tr>
<td>第四组</td>
<td>Y</td>
<td>N</td>
<td>Y</td>
<td>添加 : 81，修改 : 724，删除 : 454</td>
<td>添加 : 9504，修改 : 78451，删除 : 46229</td>
</tr>
<tr>
<td>第五组</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
<td>添加 : 70，修改 : 424，删除 : 276</td>
<td>添加 : 8953，修改 : 69865，删除 : 40738</td>
</tr>
<tr>
<td>第六组</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>添加 :200，修改 : 595，删除 : 289</td>
<td>添加 : 6119，修改 : 78899，删除 : 47316</td>
</tr>
</tbody>
</table>
<h3 id="总结（结合专题二和专题三）"><a href="#总结（结合专题二和专题三）" class="headerlink" title="总结（结合专题二和专题三）"></a>总结（结合专题二和专题三）</h3><p>单库多链接在大数据量（100w）下性能优势明显，但是多库分表在新能区间上更优，分表相比教不分表性能更好</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/linux mint等ubuntu系统全局字体不统一，楷体无法更换问题/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/10/09/linux mint等ubuntu系统全局字体不统一，楷体无法更换问题/" itemprop="url">未命名</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="linux-mint等ubuntu系统全局字体不统一，楷体无法更换问题"><a href="#linux-mint等ubuntu系统全局字体不统一，楷体无法更换问题" class="headerlink" title="linux mint等ubuntu系统全局字体不统一，楷体无法更换问题"></a>linux mint等ubuntu系统全局字体不统一，楷体无法更换问题</h2><p>此页面是关于此楷体无法更换问题的，应该是类乌班图系统都会遇到的问题: <a href="https://bugs.launchpad.net/ubuntukylin/+bug/1227034" target="_blank" rel="noopener">https://bugs.launchpad.net/ubuntukylin/+bug/1227034</a> </p>
<p>新安装的Linux mint 字体更新了以后，设置的全局字体不统一，部分字体偏小，部分字体甚至是比较小的楷体，模糊不清，十分影响观感和使用体验。</p>
<p>终端使用命令fc-match ‘sans-serif’和fc-match ‘serif’和fc-match ‘monospace’均输出类似于ukai.ttc: “AR PL UKai CN” “Book”如果删除了ukai即楷体则输出uming.ttc: “AR PL UMing CN” “Light”。<br>种种迹象表面是/etc/font/conf.d中的某文件改写错误造成.<br>新安装的linuxMint应该均会出现这样的楷体错误。 一个简单的解决办法是终端输入命令： </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install language-selector-*</span><br></pre></td></tr></table></figure>
<p>安装完成后字体会改变为</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">~ $fc-match &apos;sans-serif&apos;</span><br><span class="line">NotoSansCJK-Regular.ttc: &quot;Noto Sans CJK SC&quot; &quot;Regular&quot;</span><br><span class="line">~ $fc-match &apos;serif&apos;</span><br><span class="line">uming.ttc: &quot;AR PL UMing CN&quot; &quot;Light&quot;</span><br><span class="line">~ $fc-match &apos;monospace&apos;</span><br><span class="line">DejaVuSansMono.ttf: &quot;DejaVu Sans Mono&quot; &quot;Book&quot;</span><br></pre></td></tr></table></figure>
<p>另外建议新安装的Mint18全中文系统，使用文本编辑器比如kate执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo kate /var/lib/locales/supported.d/local</span><br></pre></td></tr></table></figure>
<p>或者</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo kate /var/lib/locales/supported.d/zh-hans</span><br></pre></td></tr></table></figure>
<p>编辑其中的一个文件即可。添加如下内容，以配置更完全详细的中文本地支持. </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">en_US.UTF-8 UTF-8</span><br><span class="line">zh_CN.UTF-8 UTF-8</span><br><span class="line">zh_CN.GBK GBK</span><br><span class="line">zh_CN GB2312</span><br><span class="line">zh_CN.GB18030 GB18030</span><br><span class="line">zh_CN.GBK GBK</span><br><span class="line">zh_HK BIG5-HKSCS</span><br><span class="line">zh_HK.UTF-8 UTF-8</span><br><span class="line">zh_SG GB2312</span><br><span class="line">zh_SG.GBK GBK</span><br><span class="line">zh_SG.UTF-8 UTF-8</span><br><span class="line">zh_TW BIG5</span><br><span class="line">zh_TW.EUC-TW EUC-TW</span><br><span class="line">zh_TW.UTF-8 UTF-8</span><br></pre></td></tr></table></figure>
<p>然后执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">Generating locales (this might take a while)...</span><br><span class="line">en_AG.UTF-8... done</span><br><span class="line">en_AU.UTF-8... done</span><br><span class="line">en_BW.UTF-8... done</span><br><span class="line">en_CA.UTF-8... done</span><br><span class="line">en_DK.UTF-8... done</span><br><span class="line">en_GB.UTF-8... done</span><br><span class="line">en_HK.UTF-8... done</span><br><span class="line">en_IE.UTF-8... done</span><br><span class="line">en_IN.UTF-8... done</span><br><span class="line">en_NG.UTF-8... done</span><br><span class="line">en_NZ.UTF-8... done</span><br><span class="line">en_PH.UTF-8... done</span><br><span class="line">en_SG.UTF-8... done</span><br><span class="line">en_US.UTF-8... done</span><br><span class="line">en_ZA.UTF-8... done</span><br><span class="line">en_ZM.UTF-8... done</span><br><span class="line">en_ZW.UTF-8... done</span><br><span class="line">zh_CN.GB2312... done</span><br><span class="line">zh_CN.GB18030... done</span><br><span class="line">zh_CN.GBK... done</span><br><span class="line">zh_CN.UTF-8... done</span><br><span class="line">zh_HK.BIG5-HKSCS... done</span><br><span class="line">zh_HK.UTF-8... done</span><br><span class="line">zh_SG.GB2312... done</span><br><span class="line">zh_SG.GBK... done</span><br><span class="line">zh_SG.UTF-8... done</span><br><span class="line">zh_TW.BIG5... done</span><br><span class="line">zh_TW.EUC-TW... done</span><br><span class="line">zh_TW.UTF-8... done</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/6/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><span class="page-number current">7</span><a class="page-number" href="/page/8/">8</a><span class="space">&hellip;</span><a class="page-number" href="/page/14/">14</a><a class="extend next" rel="next" href="/page/8/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">kyssion</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">133</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                
                  <span class="site-state-item-count">3</span>
                  <span class="site-state-item-name">分类</span>
                
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">kyssion</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
